using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Emlyn.Common.Data.DBUpdater;
using Emlyn.Website.Users;
using Emlyn.Website.UsersPresentation;

public partial class Secure_UserList : EmlynPage
{
    protected void Page_Load(object sender, EventArgs e)
    {
        DBUpdaterMain.WebsiteCode = "EmlynORegan";

        string luserId = null;

        if (Request.QueryString["userid"] != null)
            luserId = System.Web.HttpUtility.UrlDecode(Request.QueryString["userid"]);

        //
        // ArticleList details
        //

        UserQuery luq = new UserQuery();
        User luser = null;

        if (!String.IsNullOrEmpty(luserId))
        {
            luser = luq.Select(new Guid(luserId));
        }

        // doing a list here
        PresentUserList lpresentUserList = new PresentUserList();
        lpresentUserList.UserList = luq.GetUsersForWebsiteCode(DBUpdaterMain.WebsiteCode);
        lpresentUserList.UrlPrefix = "UserList.aspx?userid=[[USERID]]";

        pnlLeft.Controls.Add(lpresentUserList);

            //Button lNewArticleButton = new Button();
            //lNewArticleButton.Text = "Create New Article";
            //lNewArticleButton.Click += new EventHandler(NewArticleClick);
            //lNewArticleButton.OnClientClick = "return confirm('Create a new article?');";
            //lNewArticleButton.CssClass = pnlBody.CssClass;

            //pnlBody.Controls.Add(lNewArticleButton);

        if (luser != null)
        {
            PresentUser lpresentUser = new PresentUser();
            lpresentUser.aUser = luser;
            lpresentUser.UrlPrefix = lpresentUserList.UrlPrefix;
            lpresentUser.Editable = true;
            pnlRight.Controls.Add(lpresentUser);
            
            //HyperLink lhref = new HyperLink();
            //lhref.Text = "Back to Top Level";
            //lhref.NavigateUrl = Page.Request.Url.AbsolutePath;
            //pnlBodyTitle.Controls.Add(lhref);

            ////
            //// ArticleList details
            ////
            //PresentArticleDetail lpad = new PresentArticleDetail();
            //lpad.CssClass = "EditArticle";
            //lpad.Editable = true;
            //lpad.aArticle = larticle;
            //pnlBodyTitle.Controls.Add(lpad);

            //Panel lpnl;

            //lpnl = new Panel();
            //lpnl.CssClass = "EditArticlesParent";
            //pnlRight.Controls.Add(lpnl);

            //PresentArticleRelatedArticles lpresentArticleRelatedArticles
            //    = new PresentArticleRelatedArticles();
            //lpresentArticleRelatedArticles.aArticle = larticle;
            //lpresentArticleRelatedArticles.aArticleType = RelationshipType.ParentArticles;
            //lpresentArticleRelatedArticles.Title = "Parents: ";
            //lpresentArticleRelatedArticles.CssClass = "EditArticlesParent2";
            //lpresentArticleRelatedArticles.NavigateUrl
            //    = Page.Request.Url.AbsolutePath + @"?code=%ArticleCode%";
            //lpresentArticleRelatedArticles.Editable = true;
            //lpnl.Controls.Add(lpresentArticleRelatedArticles);

            //lpnl = new Panel();
            //lpnl.CssClass = "EditArticlesChild";
            //pnlRight.Controls.Add(lpnl);

            //lpresentArticleRelatedArticles
            //    = new PresentArticleRelatedArticles();
            //lpresentArticleRelatedArticles.aArticle = larticle;
            //lpresentArticleRelatedArticles.aArticleType = RelationshipType.ChildArticles;
            //lpresentArticleRelatedArticles.Title = "Children: ";
            //lpresentArticleRelatedArticles.CssClass = "EditArticlesChild2";
            //lpresentArticleRelatedArticles.NavigateUrl
            //    = Page.Request.Url.AbsolutePath + @"?code=%ArticleCode%";
            //lpresentArticleRelatedArticles.Editable = true;
            //lpnl.Controls.Add(lpresentArticleRelatedArticles);
        }
    }

    //protected void NewArticleClick(object sender, EventArgs e)
    //{
    //    Article larticle = new Article();

    //    larticle.ArticleName = "New Article " + larticle.ArticleID.ToString();
    //    larticle.ArticleContent = String.Empty;

    //    (new ArticleMod()).Save(larticle);

    //    Page.Response.Redirect(Page.Request.Url.ToString());
    //}
}
